|
Support Engineering Group : Interacting with Tracking Data on RabbitMQ
This page last changed on Sep 26, 2012 by kgomes.
This page documents how to subscribe to and publish to tracking data from the RabbitMQ server at MBARI. ArchitectureThe current architecture for MBARI's tracking messages is shown in the VERY large diagram below. Consuming messagesJava SubscriberIf you are interested in consuming tracking messages from the RabbitMQ server using Java, you are in the right spot. The first thing you will need to do is get the supporting libraries from RabbitMQ website. https://www.rabbitmq.com/download.html From the Java client download, you will need several libraries on your classpath:
After that, you can write your client code to connect up to and listen for tracking related messages. Below is some example code to connect to MBARI's messaging server and subscribe to the tracking message exchange. Some things to note:
Java Code package org.mbari.odss.messaging;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.QueueingConsumer;
public class TestConnection {
// The name of the exchange to connect to
private static final String EXCHANGE_NAME = "auvs_pb";
// The main method
public static void main(String[] argv) throws java.io.IOException,
java.lang.InterruptedException {
// The RabbitMQ ConnectionFactory
ConnectionFactory factory = new ConnectionFactory();
// MBARI's messaging server is 'messaging.shore.mbari.org
factory.setHost("messaging.shore.mbari.org");
// RabbitMQ uses virtual hosts as a top level concept.
// MBARI's virtual host is 'trackingvhost'
factory.setVirtualHost("trackingvhost");
// Now set your user credentials (need to get this set up with MBARI)
factory.setUsername("username");
factory.setPassword("password");
// Create a connection
Connection connection = factory.newConnection();
// Create a channel
Channel channel = connection.createChannel();
// Create a queue that you will pull messages from (must be unique)
channel.queueDeclare("my_queue_name", true, false, true, null);
// Bind the queue to the proper exchange
channel.queueBind("my_queue_name", EXCHANGE_NAME, "");
// Now print a message on how to get out to the user
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
// Create a consumer to listen for messages on the proper channel
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume("my_queue_name", true, consumer);
// Enter infinite loop
while (true) {
// Block and listen for message
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
// Extract the message body and print it to the console
String message = new String(delivery.getBody());
System.out.println(" [x] Received '" + message + "'");
}
}
}
Python ConsumerThis is still to be done, but using the above information and this here: https://www.rabbitmq.com/devtools.html#python-dev You should be able to figure it out ... Publishing MessagesIf you want to get your platforms positions into the tracking system, there are a couple of ways: Email messages or direct interaction with RabbitMQ. Email PublisherIf you want to email your positions, you must first decide what type of platform you fall into. The types that are currently supported are:
Once you have decided, that determines what email address to send your messages to:
Then you just need to put the proper information into the subject of the message and leave the body blank: platformName,timestamp,longitude,_latitude Where:
Java PublisherTo be documented ... Python PublisherTo be documented ... |
| Document generated by Confluence on Feb 03, 2026 16:22 |